#version 330 core

in vec2 TexCoords;

uniform float Time;
uniform sampler2D image;
uniform sampler2D image2;

out vec4 FragColor;

//正片叠底
vec4 multipy(vec4 base, vec4 blend){
    return base * blend;
}
//滤色
vec4 screen(vec4 base, vec4 blend){
    return 1.0 - (1.0 - base) * (1.0 - blend);
}
//变暗
vec4 darken(vec4 base, vec4 blend){
    return min(base, blend);
}
//变亮
vec4 lighten(vec4 base, vec4 blend){
    return max(base, blend);
}

mat2 scale(vec2 scale)
{
    return mat2(scale.x, 0.0, 0.0, scale.y);
}

void main()
{
	vec2 coord = TexCoords*2.0;
	
    vec4 color1 = multipy(texture2D(image, coord), texture2D(image2, coord));
	vec4 color2 = screen(texture2D(image, coord), texture2D(image2, coord));
	vec4 color3 = darken(texture2D(image, coord), texture2D(image2, coord));
	vec4 color4 = lighten(texture2D(image, coord), texture2D(image2, coord));
	
	vec4 colorA = color1 * step(coord.x, 1.0) * step(1.0, coord.y);
	vec4 colorB = color2 * step(1.0, coord.x) * step(1.0, coord.y);
	vec4 colorC = color3 * step(coord.x, 1.0) * step(coord.y, 1.0);
	vec4 colorD = color4 * step(1.0, coord.x) * step(coord.y, 1.0);
	
    FragColor = colorA + colorB + colorC + colorD;
}
